﻿using System;
using System.Collections.Generic;
using System.Text;
using WcfContract;
using System.ServiceModel;
using System.Threading;

namespace TestServer
{
    [ServiceBehavior( ConcurrencyMode = ConcurrencyMode.Multiple,
    InstanceContextMode = InstanceContextMode.Single )]
    class ServiceBuffered : IServiceBufferedContract
    {
        ICallbackContract callback;
        public void SimpleFunctionCall()
        {
            if( callback == null )
                callback = OperationContext.Current.GetCallbackChannel<ICallbackContract>();
        }

        public void Test(byte[] data, int callbacks) 
        {
            if (data.Length < 0)
                callback.Reply(data);

            for( int i = 0; i < callbacks; ++ i )
                callback.Reply(data);
        }

        public void OneWay(byte[] data)
        {
            if( data.Length < 0 )
                callback.Reply(data);
        }

        public byte[] Recceive()
        {
            return new byte[1000];
        }
    }
}
